/* eslint valid-jsdoc: "off" */

'use strict'

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {})

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1653811076404_4063'

  config.cluster = {
    listen: {
      path: '',
      port: 5000,
      hostname: '0.0.0.0'
    }
  }

  // 配置跨域
  config.security = {
    csrf: {
      enable: false
    },
    domainWhiteList: ['*'] //允许访问接口的白名单，例如：http://localhost:8080 *表示均可访问
  }

  // 配置跨域
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
  }

  config.bodyParser = {
    jsonLimit: '10mb',
    formLimit: '10mb'
  }

  // 数据库配置项
  config.sequelize = {
    dialect: 'mysql',
    host: 'localhost',
    port: 3306,
    database: 'evo-proj-sql',
    username: 'root',
    password: 'root',
    // 配置数据库时间为东八区北京时间
    timezone: '+08:00',
    define: {
      freezeTableName: true // 强制表名称等于模型名称
    }
  }

  // add your middleware config here
  config.middleware = []

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  }

  return {
    ...config,
    ...userConfig
  }
}
